//模型控制断面
Ext.define("Admin.view.sys.DdsMConsec", {
    extend: "Admin.common.container.BaseContainer",
    xtype: "ddsMConsec",
    alias: "ddsMConsec",
    requires: [
        "Ext.panel.Panel",
        "Ext.grid.Panel",
        "Ext.button.Button",
        "Admin.common.form.SearchFormPanel",
        "Admin.store.sys.DdsMConsec",
    ],
    controller: "ddsMConsecController",
    // style: "border: 1px solid #ccc",
    border: false,
    layout: 'fit',
    width: '100%',
    height: 200,
    items: [{
        title: "模型控制断面",
        xtype: "baseGridPanel",
        reference: "riverMCGrid",
        border: true,
        stripeRows: true, //斑马纹效果
        loadMask: true, //loading效果
        columns: [{
                header: "污染发生河段",
                dataIndex: "rcd",
                align: "center",
                flex: 1,
                renderer: function(value, record) {
                    // console.log(value)
                    return getRnm(value);
                }
            },
            {
                header: "河道断面ID",
                dataIndex: "secid",
                align: "center",
                flex: 1,
            },
            {
                header: "上下边界标志",
                dataIndex: "secflag",
                align: "center",
                flex: 1,
            },
            {
                header: "距离上一个断面距离",
                dataIndex: "lendelta",
                align: "center",
                flex: 1,
            },
            {
                header: "距离上边界的里程(km)",
                dataIndex: "lenup",
                align: "center",
                flex: 1,
            },
            {
                header: "断面名称",
                dataIndex: "secnm",
                align: "center",
                flex: 1,
            },
            {
                header: "断面类型",
                dataIndex: "stype",
                align: "center",
                flex: 1,
            },
            {
                header: "河流标识",
                dataIndex: "river",
                align: "center",
                flex: 1,
                renderer: function(value, record) {
                    if (value == '02') {
                        return '抚河';
                    } else {
                        return '袁河';
                    }
                }
            },
            {
                xtype: "actioncolumn",
                text: "操作",
                align: "center",
                width: 100,
                // sortable: false,
                // menuDisabled: true,
                items: [{
                        iconCls: "x-fa fa-edit",
                        tooltip: "编辑",
                        handler: "riverUpdate"
                    },
                    {
                        iconCls: "x-fa fa-times-circle",
                        tooltip: "删除",
                        handler: "riverDelete"
                    }
                ]
            }
        ],
        store: {
            type: "ddsMConsec"
        },
        tbar: [{
                xtype: "searchFormPanel",
                columns: 2,
                items: [{
                    xtype: "dicComboBox",
                    dicType: 'riverRcd',
                    maxWidth: 300,
                    fieldLabel: "污染发生河段",
                    labelWidth: 100,
                    reference: 'serchRcd',
                    listeners: {
                        added: function() {
                            var store = this.getStore();
                            store.clearFilter();
                            store.filter({
                                property: 'river',
                                value: config.RIVER
                            });
                        }
                    }
                }, ]
            },
            "->",
            {
                xtype: "button",
                iconCls: "x-fa fa-search",
                text: "查询",
                handler: "riverSearch"
            },
            {
                xtype: "button",
                iconCls: "x-fa fa-save",
                text: "新增",
                handler: "riverAdd"
            }
        ],
        bbar: {
            xtype: "pagingtoolbar",
            autoLoad: true,
            displayInfo: true,
            displayMsg: "显示从第{0}条数据到第{1}条数据，共{2}条数据",
            emptyMsg: "没有记录"
        }
    }]
});

//专家库新增/修改的form表单
Ext.define("Admin.view.sys.RiverMCForm", {
    // extend: 'Ext.form.Panel',
    extend: "Admin.common.form.BaseFormPanel",
    xtype: "riverMCForm",
    alias: "riverMCForm",
    bodyPadding: 10,
    layout: "anchor",
    defaults: {
        anchor: "100%",
        labelWidth: 140,
        labelAlign: "right"
    },
    defaultType: "textfield",
    margin: "0 0 10 0",
    items: [{
            xtype: "combobox",
            fieldLabel: "污染发生河段",
            valueField: "rcd",
            displayField: "rnm",
            name: "rcd",
            disabled: false,
            emptyText: "请选择河段名称",
            reference: "riverRcd",
            listeners: {
                added: function(combo) {
                    var _that = this;
                    var store = Ext.create('Ext.data.Store', {
                        fields: ['rnm', 'rcd'],
                        data: mriverList
                    });
                    store.clearFilter();
                    store.filter({
                        property: 'river',
                        value: config.RIVER
                    });
                    combo.setStore(store);
                },
                change: function(me, newVlaue, oldValue, eOpts) {
                    var that = this;
                    var riverRcd = that.getStore().getData().items;
                    riverRcd.forEach(function(item) {
                        if (newVlaue == item.data.rcd) {
                            that.ownerCt.getForm().findField('river').setValue(item.data.river);
                        }
                    })
                }
            }
        },
        {
            // xtype: "combobox",
            fieldLabel: "断面名称",
            // emptyText: "请选择断面名称",
            // editable:false ,
            // disabled: false,
            allowBlank: false,
            // valueField: "secnm",
            // displayField: "secnm",
            name: "secnm",
            listeners: {
                // added: function (combo) {
                // 	var _that = this;
                // 	var store = Ext.create('Ext.data.Store', {
                // 		fields: ['fieldnm'],
                // 		data: [{'fieldnm':'Q'},{'fieldnm':'Z'},{'fieldnm':'INQ'},{'fieldnm':'RZ'}]
                // 	});
                // 	combo.setStore(store);
                // }
            }
        },
        {
            // xtype: "combobox",
            fieldLabel: "断面类型",
            allowBlank: false,
            name: "stype",
            listeners: {}
        },
        {
            fieldLabel: "河道断面ID",
            allowBlank: false,
            name: "secid",
        },
        {
            fieldLabel: "上下边界标志",
            allowBlank: false,
            name: "secflag",
        },
        {
            fieldLabel: "距离上一个断面的距离",
            allowBlank: false,
            name: "lendelta",
        },
        {
            fieldLabel: "距离上边界的里程km",
            allowBlank: false,
            name: "lenup",
        },
        {
            fieldLabel: "河流标识",
            editable: false,
            name: "river",
        },
    ]
});